package cn.edu.hit.core.message;

import cn.edu.hit.core.MappedLoader;

import java.util.Map;

public final class MessageLoader extends MappedLoader<String, Map, Map, Long, MessageAdapter> {
    /**
     * 初始化
     */
    private MessageLoader() {
        super(MessageAdapter.class);
    }

    private static MessageLoader ourInstance = null;

    public static MessageLoader getInstance() {
        if (ourInstance == null) {
            synchronized (MessageLoader.class) {
                if (ourInstance == null) {
                    ourInstance = new MessageLoader();
                }
            }
        }
        return ourInstance;
    }

    @Override
    protected MessageAdapter defaultAdapter() {
        return this.adapters.stream().filter(x -> x.accept("Random")).findAny().get();
    }
}
